-
Notifications
You must be signed in to change notification settings - Fork 851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Fix CSndLossList::insert with negative offset #1359
[core] Fix CSndLossList::insert with negative offset #1359
Conversation
0451d9a
to
4236da8
Compare
4236da8
to
a2b236c
Compare
a2b236c
to
34a7134
Compare
srtcore/list.cpp
Outdated
// The size of the CSndLossList should be at least the size of the flow window. | ||
// It means that all the packets sender has sent should fit within m_iSize. | ||
// If the new loss does not fit, there is some error. | ||
LOGC(mglog.Error, log << "IPE: New loss record is too old. Ignoring. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this situation can be described as IPE here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW. Does it mean that offset
is allowed to be negative in general, as long as it fits in the range from the current head and size?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially the following can happen:
- Two packets with sequence numbers
A
andB
(A <% B
) are reported as lost. - Packet
A
is retransmitted and removed from the loss list. - Packet
A
is reported lost again, so thatCSeqNo::seqoff(m_caSeq[m_iHead].seqstart = B, seqno1 = A) < 0
.
So negative offset is allowed, it just has to fit into the list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't however head moved forward after getting ACK? Isn't then a sequence that is earlier than head a sequence before the ACK? If this is true, then I can only imagine such a situation if reordering happened and the ACK that confirms the packet in question comes earlier than the lossreport that reports this sequence as lost, although it's actually outdated.
If this is the case, however, then it should be first checked if the upper sequence is below the head, and only if so should the loss record be rejected as a whole. Otherwise at least the range between the head and the upper sequence be recorded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The head is moved forward after the loss record is extracted and the corresponding packet is retransmitted.
If the same packet is reported lost again, it is placed before the head (negative offset
), and the head position is updated.
// offset < 0
const int offset = CSeqNo::seqoff(m_caSeq[m_iHead].seqstart, seqno1);
As I wrote above, a negative offset is allowed, it just has to fit into the list.
The loc
identifies the position in the list to insert at. It is not allowed to be negative, otherwise it is out of bounds memory access.
int loc = (m_iHead + offset + m_iSize) % m_iSize;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I understand that negative loc within the bounds is allowed, but I don't think it's correct to reject the whole report because of that. It should reject it only if the upper bound is behind the seqstart
, and if it's not, the loss record should be accepted with the lower bound adjusted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added check for upper sequence.
Work in progress.
Probably
CSndLossList::insert(..)
should return-1
on failure, but then it needs to be properly handled inCUDT
.Related to #1000.
Suggestion by @ethouris